<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>ECMAsctipt入门介绍</title>
</head>
<body>
    <script>
        const map0 = new Map()
            .set(1, 'a')
            .set(2, 'b')
            .set(3, 'c');

        map0.forEach(function(value, key, map) {
            console.log("Key: %s, Value: %s,map:%s", key, value,map);
        });

        let obj = {"a":1, "b":2};
        console.log(Object.entries(obj))
        let map = new Map(Object.entries(obj));
        console.log(map)

        const _counter = new WeakMap();
        const _action = new WeakMap();
        
        class Counterdown {
            constructor(counter,action){
                _counter.set(this,counter);
                _action.set(this,action)
            }
            dec() {
                let counter = _counter.get(this);
                if(counter<1){
                    return 
                }
                counter--;
                _counter.set(this,counter);
                if (counter === 0){
                    _action.get(this)();
                }
            }
        }
        const c = new Counterdown(2,()=>console.log("none"));

        c.dec()
        c.dec()
    </script>
</body>
</html>